package com.sxj.web.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author 石小俊
 * @date 2024年02月28日 18:28
 * 绘制添加页面
 */
@WebServlet("/showAddEmp")
public class ShowAddEmpServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 响应乱码,需要指定响应格式与编码
        // text/html表示当前文本格式是一个html文本
        // charset=utf-8表示当前字符集为utf-8
        // 两者之间以分号分割
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        out.print(" <!DOCTYPE html> ");
        out.print(" <html lang=\"en\"> ");
        out.print(" <head> ");
        out.print("     <title>添加员工信息</title> ");
        out.print(" </head> ");
        out.print(" <body> ");
        out.print(" <h1>添加员工</h1> ");
        out.print(" <a href=\"findAll\">返回员工列表</a> ");
        out.print(" <hr> ");
        out.print(" <form action=\"addEmp\" method=\"get\"> ");
        out.print("     姓名:<input type=\"text\" name=\"name\"><br> ");
        out.print("     工资:<input type=\"text\" name=\"salary\"><br> ");
        out.print("     性别: ");
        out.print("     <input type=\"radio\" name=\"gender\" value=\"man\">男 ");
        out.print("     <input type=\"radio\" name=\"gender\" value=\"woman\">女<br> ");
        out.print("     学历: ");
        out.print("     <select name=\"edu\"> ");
        out.print("         <option value=\"-1\">请选择</option> ");
        out.print("         <option value=\"1\">大专</option> ");
        out.print("         <option value=\"2\">本科</option> ");
        out.print("         <option value=\"3\">研究生</option> ");
        out.print("         <option value=\"4\">博士生</option> ");
        out.print("     </select><br> ");
        out.print("     兴趣: ");
        out.print("     <input type=\"checkbox\" name=\"hobbies\" value=\"eat\">吃饭 ");
        out.print("     <input type=\"checkbox\" name=\"hobbies\" value=\"sleep\">睡觉 ");
        out.print("     <input type=\"checkbox\" name=\"hobbies\" value=\"study\">学习<br> ");
        out.print("     <input type=\"submit\" value=\"添加\"> ");
        out.print(" </form> ");
        out.print(" </body> ");
        out.print(" </html> ");
    }

}
